home *** CD-ROM | disk | FTP | other *** search
- /*
- Sample ICI script for NetFinder.
-
- This script Resolves Domain Names.
-
- The purpose of this script is for technical support when things are not
- working...eg DNS not setup properly.
- You can also use it for other purposes.
-
- NOTES:
- o Full ICI programming syntax can be obtained from
- <http://www.zeta.org.au/~atrn/ici/documentation.html>
-
- (c) Copyright 2000 Peter Li.
- */
-
-
- /* define a few variables */
- auto TIMEOUT = 3;
- auto query = "";
- auto name = "";
-
- try {
-
- /* prompt the user for input. */
-
- if (MICI.Ask("Enter a name to resolve: eg ╥ftp.cdrom.com╙ or ╥203.14.50.123╙",
- "" /* inDefaultAnswer */,
- &query) == 0)
- {
- /* if user didnt cancel, continue. Else do nothing. */
-
- // remove any leading and trailing spaces...
- query = query ~~ # *([^ ]*) *#;
-
- if (query ~ #[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+#)
- {
- // user typed in a dot IP address so resolve it to the english name...
- if (NFAddressToString(NFStringToAddress(query, TIMEOUT), &name, TIMEOUT) != 0)
- name = "unresolved address";
- }
- else
- {
- // user typed in an english name address so resolve it to a dot IP address...
- auto ip = 0;
-
- ip = NFStringToAddress(query, TIMEOUT);
-
- if (ip != 0)
- {
- name = sprintf("%d.%d.%d.%d",
- (ip >> 24) & 0xFF,
- (ip >> 16) & 0xFF,
- (ip >> 8) & 0xFF,
- (ip >> 0) & 0xFF
- );
- }
- else
- name = "unresolved address";
- }
-
- printf( "\n"
- "Your Query: %s\n"
- "Resolves To: %s\n\n", query, name);
- }
- } onerror {
- printf("'iciMICI.so' module is missing.\n");
- }
-
-